using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    /// <summary>
    /// 取消延迟服务
    /// 参数组1：1定位方式（1.根据服务cid，2.根据实体tag或mcid)
    /// 参数组2：1定位用id
    /// </summary>
    public class ExecCancelDelayService : BaseServiceExecution
    {
        public override void Execute(LevelRegion region, LevelPlayer player)
        {
            var config = _config as ExecParamCancelDelayService;

            bool isByEntity = config.isByEntity;
            int searchId = config.searchId;

            if (isByEntity)
            {
                //特殊处理：查找自己触发的延迟服务
                int tagOrMcid = searchId == 0 ? triggerEntity.entityConfig.id : searchId;
                region.level.delayServiceMgr.CancelDelayByEntityTagOrMcid(tagOrMcid);
            }
            else
            {
                region.level.delayServiceMgr.CancelDelayByServiceCid(searchId);
            }
        }
    }
}
